﻿using HealthcareSystem.API.Read.Application.Command.ChronicDisease;
using HealthcareSystem.Domain;
using MediatR;
using WeekExam.PassPort.ErrorCode;
using WeekExam.PassPort.Infrastructure.Interface;

namespace HealthcareSystem.API.Read.Application.CommandHandel.ChronicDisease
{
    public class UserInfoListCommandHandler : IRequestHandler<UserInfoListCommand, ApiResult<List<Login>>>
    {

        private readonly IBaseRepository<Login> userRepository;

        public UserInfoListCommandHandler(IBaseRepository<Login> userRepository)
        {
            this.userRepository = userRepository;
        }

        public Task<ApiResult<List<Login>>> Handle(UserInfoListCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<Login>> result = new ApiResult<List<Login>>();
            result.Code = ResultCode.查询成功;
            result.Message = ResultCode.查询成功.ToString();

            result.Data = userRepository.GetAll().ToList();
            return Task.FromResult(result);
        }
    }
}
